package com.example.second_home_work

import android.os.Bundle
import android.util.TypedValue
import android.widget.Button
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {

    val export= programexport()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets

        }

        val button: Button=findViewById(R.id.button)
        val scrollview : ScrollView=findViewById(R.id.ll)
        val linearLayout : LinearLayout=findViewById(R.id.linear)
        val button1: Button=findViewById(R.id.button1)
        val textView1=findViewById<TextView>(R.id.text1)
        val spinner: Spinner=findViewById(R.id.spinner)
        button1.setOnClickListener{
            val str=spinner.selectedItem.toString()
            textView1.text=export.getlanguage(str)
        }
        button.setOnClickListener{
            val textView= TextView(this)
            textView.layoutParams= LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT
            )
            textView.setText(resources.getString(R.string.text_view))
            textView.textSize=20f
            textView.setTextColor(resources.getColor(R.color.white))
            linearLayout.addView(textView)
        }
        scrollview.post{
            scrollview.fullScroll(ScrollView.FOCUS_DOWN)
        }
    }
}